package m.app.model;

import m.base.model.UserInfo;
import m.common.model.*;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.QueryCondition;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@TableMeta(name = "ta_app_login", description = "app登录")
public class AppLogin extends Model implements MigrationModel {
    @Override
    public List<String> migrationOidList(String storeOid) throws Exception {
        return ModelQueryList.getModelList(this.getClass(),new String[]{"oid"},null,
                        QueryCondition.eq("user.store.oid",storeOid))
                .stream().map(Model::getOid).collect(Collectors.toList());
    }
    @LinkTableMeta(name="user_oid",table= UserInfo.class,description="用户")
    private UserInfo user;
    @FieldMeta(name="login_date",type= FieldType.DATE,description="登录时间")
    private Date loginDate;

    public UserInfo getUser() {
        return user;
    }

    public void setUser(UserInfo user) {
        this.user = user;
    }

    public Date getLoginDate() {
        return loginDate;
    }

    public void setLoginDate(Date loginDate) {
        this.loginDate = loginDate;
    }
}
